/*    */ package com.newcrm.webapi.sub;
/*    */ 
/*    */ import com.newcrm.bean.User;
/*    */ import com.newcrm.db.UserManager;
/*    */ import com.newcrm.exception.DBException;
/*    */ import com.newcrm.exception.NotFoundException;
/*    */ import com.newcrm.thread.LuceneThread;
/*    */ import com.newcrm.util.Util;
/*    */ import com.newcrm.webapi.AbstractAction;
/*    */ import com.newcrm.webapi.AbstractHttpServlet;
/*    */ import java.io.IOException;
/*    */ import java.io.PrintWriter;
/*    */ import java.sql.SQLException;
/*    */ import javax.servlet.ServletException;
/*    */ import javax.servlet.http.HttpServletRequest;
/*    */ import javax.servlet.http.HttpServletResponse;
/*    */ import net.sf.json.JSONObject;
/*    */ import org.apache.log4j.Logger;
/*    */ 
/*    */ public class ChangeUserOwner extends AbstractAction
/*    */ {
/* 31 */   private static Logger logger = Logger.getLogger(ChangeUserOwner.class
/* 32 */     .getName());
/*    */ 
/* 34 */   private String indexPath = null;
/*    */ 
/*    */   public ChangeUserOwner(AbstractHttpServlet servlet, String indexPath) {
/* 37 */     super(servlet);
/* 38 */     this.indexPath = indexPath;
/*    */   }
/*    */ 
/*    */   public void parse(HttpServletRequest request, HttpServletResponse response)
/*    */     throws IOException, ServletException, NotFoundException
/*    */   {
/* 44 */     response.setContentType("text/html;charset=utf-8");
/* 45 */     PrintWriter out = response.getWriter();
/* 46 */     JSONObject jsonObject = new JSONObject();
/*    */ 
/* 49 */     if (!super.getLoginUser(request).isAdmin) {
/* 50 */       jsonObject.put("error", "1");
/* 51 */       out.println(jsonObject);
/* 52 */       out.flush();
/* 53 */       out.close();
/* 54 */       return;
/*    */     }
/*    */ 
/* 57 */     String oldOwner = 
/* 58 */       Util.getURLParameter(request.getParameter("oldOwner"));
/*    */ 
/* 60 */     String newOwner = 
/* 61 */       Util.getURLParameter(request.getParameter("newOwner"));
/*    */ 
/* 63 */     if ((oldOwner == null) || (oldOwner.length() == 0) || (newOwner == null) || 
/* 64 */       (newOwner.length() == 0)) {
/* 65 */       jsonObject.put("error", "1");
/* 66 */       out.println(jsonObject);
/* 67 */       out.flush();
/* 68 */       out.close();
/* 69 */       return;
/*    */     }
/*    */ 
/* 72 */     UserManager manager = new UserManager();
/*    */     try {
/* 74 */       manager.modifyOwner(oldOwner, newOwner);
/* 75 */       jsonObject.put("error", "0");
/*    */ 
/* 78 */       new LuceneThread(this.indexPath, false).start();
/*    */     } catch (DBException e) {
/* 80 */       jsonObject.put("error", "1");
/* 81 */       logger.warn("modify Owner failed", e);
/*    */     } catch (SQLException e) {
/* 83 */       jsonObject.put("error", "1");
/* 84 */       logger.warn("modify Owner failed", e);
/*    */     }
/* 86 */     out.println(jsonObject);
/* 87 */     out.flush();
/* 88 */     out.close();
/*    */   }
/*    */ }

/* Location:           C:\E\referenceProject\CRM参考\qikebao\WEB-INF\lib\qikebao.jar
 * Qualified Name:     com.newcrm.webapi.sub.ChangeUserOwner
 * JD-Core Version:    0.6.1
 */